﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfApp63.Models
{
    public class Clazz : INotifyPropertyChanged
    {
        private string name = null!;
        public string Name
        {
            get => name;
            set
            {
                name = value;
                string oldValue = nameof(value);
                string oldValue1 = nameof(Name);
                //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name"));
                OnPropertyChanged("Name");
            }
        }

        private ObservableCollection<Student> students =null!;
        public ObservableCollection<Student> Students
        {
            get => students;
            set
            {
                students = value; OnPropertyChanged("Students");
            }
        }

        public event PropertyChangedEventHandler? PropertyChanged;
        private void OnPropertyChanged(string propertyName)
        {
                string oldValue = nameof(propertyName);
            //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(propertyName)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        public Clazz(string name,  ObservableCollection<Student> students)
        {
            Name = name;
            Students = students;
        }
    }
}
